<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>我要询价</title>
<link rel="stylesheet" type="text/css" href="/css/front/conn.css"/>
<link rel="stylesheet" type="text/css" href="/css/front/list7.css"/>
    <script src="/js/plugs/jquery.js"></script>
    <script src="/js/admins/base.js"></script>
    <script src="/js/plugs/validate.js"></script>

    <script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>

    <style>

	.del {
		background: #d9534f !important;
		color: #fff !important;
		border: 1px solid #d9534f !important;
	}
	.cor h6 {
       color: #999;
       font-size: 13px;
    }
	
	.cor button.btn {
		margin:0 auto !important;
}

    </style>

</head>

<body >
<!-- 头部导航开始 -->
{# include file="$tpl_root_path/front/public/_header.html" #}
<!-- 头部导航结束 -->




<!-- 合作begin -->
<div class="cor"  style="margin-top: 150px;">
    <h6><a href="/cooperate/myQuoted.html" >报价系统</a>&nbsp;>&nbsp;我要询价</h6>
    <div class="process">
        <img src="/images/logo/pro2.png" alt="" />
    </div>

    <div class="cor content-form-box" id="step2Form"    >

        <form class="step2" method="post"      >
            <input type="hidden" value="{#$smarty.get.id #}" id="resId"  />
            <input type="reset" name="reset" class="reset" style="display: none;" />
            <ul class="product"> 
                <li id="productCategory">
                    <div><i>*</i><span>选择产品分类：</span></div>
                        <div class="check-list product-category-radios">
                            <label>
                                <input type="radio" name="productCategory" value="1" class="tianhua category-radio"   />
                                <span>天花</span>
                            </label>
                            <label>
                                <input type="radio" name="productCategory" value="2" class="qiangban category-radio"  />
                                <span>墙板</span>
                            </label>
                            <label>
                                <input type="radio" name="productCategory" value="3"  class="dengju category-radio"  />
                                <span>灯具</span>
                            </label>

                            <label>
                                <input type="radio" name="productCategory" value="4" class="fengkou category-radio" />
                                <span>风口</span>
                            </label>
                            <label>
                                <input type="radio" name="productCategory" value="5" class="tijiaoxian category-radio"  />
                                <span>踢脚线</span>
                            </label>
                            <label>
                                <input type="radio" name="productCategory" value="6" class="chuanglian category-radio"  />
                                <span>窗帘 </span>
                            </label>

                        </div>

                </li>



                <li class="raw typeSecond "   id="typeSecond"  >  </li>
                <li class="raw typeSecondHalf "   id="typeSecondHalf"  >  </li>
                <li class="raw typeThird"   id="typeThird"  >  </li>
                <li class="raw typeFourth"   id="typeFourth"  >  </li>
                <li class="raw typeFifth"   id="typeFifth"  >  </li>

            </ul>

            <div style="margin-left:300px; margin-top:15px;" >
                <div style="float: left">
                    <button class="btn save"  id="save" type="button"    name="save" value="0" style="background: #009C4C;color: #fff;"  onclick="saveform(this)"   >保存 </button>
                </div>

                <div style="float: left;margin-left:110px;">
                    <button class="btn del" id="del" type="button" name="del" value="0"  onclick="dell(this)"   > 删除 </button>
                </div>
            </div>

        
    </div>

</div>
<!-- 合作over -->

<div class="aa"></div>

<div class="count">
    <button class="btn addProduct"  type="button"   onclick="addProduct()" style="background: #337ab7;">+添加产品  </button>
</div>

<div class="bg"></div>

<!-- 统计begin -->
<div class="count">
    <div id="count-view-box" ></div>
    
    <button class="btn" type="button" name="step2"  value="2"  onclick="checkStep()">下一步</button>

</div>
<!-- 统计over -->

</form>








<!-- 咨询栏begin -->
{# include file="$tpl_root_path/front/public/_contact.html" #}

<!-- 咨询栏over -->



<!-- 底部begin -->
{# include file="$tpl_root_path/front/public/_footer.html" #}
<!-- 底部over -->



</body>
</html>


<script type="text/javascript">

        var arrPubTypes = 		[
		 {'name':'天花','types':'1,2,3','isShowWhichType':1,'isShowProductType':true,'isShowNum':1,'isShowSize':false,'isShowPower':false,'fitSmallpoxType':false,'surfacePreparation':false,'colorNum':false,'height':false},
		 {'name':'墙板','types':'1,2,3','isShowWhichType':1,'isShowProductType':true,'isShowNum':2,'isShowSize':false,'isShowPower':false,'fitSmallpoxType':false,'surfacePreparation':false,'colorNum':false,'height':false},
		 {'name':'灯具','types':'1,2,3','isShowWhichType':2,'isShowProductType':true,'isShowNum':3,'isShowSize':false,'isShowPower':true,'fitSmallpoxType':true,'surfacePreparation':true,'colorNum':true,'height':false},
		 {'name':'风口','types':'1,2,3','isShowWhichType':3,'isShowProductType':false,'isShowNum':4,'isShowSize':true,'isShowPower':false,'fitSmallpoxType':true,'surfacePreparation':true,'colorNum':true,'height':false},
		 {'name':'踢脚线','types':'1,2','isShowWhichType':1,'isShowProductType':false,'isShowNum':5,'isShowSize':false,'isShowPower':false,'fitSmallpoxType':false,'surfacePreparation':false,'colorNum':false,'height':true},
		 {'name':'窗帘','types':'1,4,5,6,7','isShowWhichType':1,'isShowProductType':false,'isShowNum':6,'isShowSize':false,'isShowPower':false,'fitSmallpoxType':false,'surfacePreparation':false,'colorNum':false,'height':false},
		];
		
 
		var $inputTupes =  $(".category-radio");
		
		$inputTupes.each(function(i, e) {
			var $types = arrPubTypes[i];
            $(this).bind('click',function(){
				showTypeSecond($types['types'],$types['isShowWhichType'],$types['isShowProductType'],$types['isShowNum'],$types['isShowSize'],$types['isShowPower'],
                        $types['fitSmallpoxType'],$types['surfacePreparation'],$types['colorNum'],$types['height'],$(this));
			});
        });
		
   

//筛选材料显示的类型
    var arrPublicType = ['','铝合金','不锈钢','镀锌钢板','太阳布','柔纱','竹板','木板'];

    function showTypeSecond(types,isShowWhichType,isShowProductType,isShowNum,isShowSize,isShowPower,fitSmallpoxType,surfacePreparation,colorNum,height,$self){


        isShowWhichType=isShowWhichType?isShowWhichType:false;
        isShowProductType=isShowProductType?isShowProductType:false;
        isShowNum=isShowNum?isShowNum:false;
        isShowSize=isShowSize?isShowSize:false;
        isShowPower=isShowPower?isShowPower:false;
        fitSmallpoxType=fitSmallpoxType?fitSmallpoxType:false;//配合天花类型
        surfacePreparation=surfacePreparation?surfacePreparation:false;//选择表面处理
        colorNum=colorNum?colorNum:false;//国际色号
        height=height?height:false;//高度







        var arrTypes = types.split(',');
        var paramsTypes = [];
        var strParamsType = '';
        if(arrTypes.length == 0){
            return false;
        }
        for(var i=0;i<arrTypes.length;i++){
            var tid = arrTypes[i];
            if(arrPublicType[tid]){
                paramsTypes.push(arrPublicType[tid]);
            }
        }

        strParamsType = paramsTypes.join(',');
//        alert(strParamsType);

        if(isShowWhichType=='1'){//显示材料类型
            isShowWhichType='1';
        }else if(isShowWhichType=='2'){//显示灯具类型
            isShowWhichType='2';
        }else if(isShowWhichType=='3'){//显示风口类型
            isShowWhichType='3';
        }



        if(isShowProductType){//产品类型是否显示
            isShowProductType='1';
        }else {
            isShowProductType='0';
        }

        if(isShowNum=='1'){//天花数量
            isShowNum='1';
        }else if(isShowNum=='2') {//墙板数量
            isShowNum='2';
        }else if(isShowNum=='3') {//灯具数量
            isShowNum='3';
        }else if(isShowNum=='4') {//风口数量
            isShowNum='4';
        }else if(isShowNum=='5') {//踢脚线数量
            isShowNum='5';
        }else if(isShowNum=='6') {//窗帘数量
            isShowNum='6';
        }else {
            isShowNum=='0'
        }

        if(isShowSize){//尺寸
            isShowSize='1';
        }else {
            isShowSize='0';
        }


        if(isShowPower){//功率
            isShowPower='1';
        }else {
            isShowPower='0';
        }

        if(fitSmallpoxType){//配合天花类型
            fitSmallpoxType='1';
        }else {
            fitSmallpoxType='0';
        }

        if(surfacePreparation){//选择表面处理
            surfacePreparation='1';
        }else {
            surfacePreparation='0';
        }


        if(colorNum){//国际色号
            colorNum='1';
        }else {
            colorNum='0';
        }

        if(height){//高度
            height='1';
        }else {
            height='0';
        }

        var level = 0;
        if($self.data('level')){
            level = $self.data('level');
        }

        if(level > 0){
            var $selftypeSecondHalf = $("#typeSecondHalf"+level );
        }else{
            var $selftypeSecondHalf = $("#typeSecondHalf");
        }

        if(level > 0){
            var $selftypeThird = $("#typeThird"+level );
        }else{
            var $selftypeThird = $("#typeThird");
        }

        if(level > 0){
            var $selftypeFourth = $("#typeFourth"+level );
        }else{
            var $selftypeFourth = $("#typeFourth");
        }

        if(level > 0){
            var $selftypeFifth = $("#typeFifth"+level );
        }else{
            var $selftypeFifth = $("#typeFifth");
        }

        $selftypeSecondHalf.css('display','none');
        $selftypeThird.css('display','none');
        $selftypeFourth.css('display','none');
        $selftypeFifth.css('display','none');


        if(level > 0){
            var $form = $("#step2Form"+level );
        }else{
            var $form = $("#step2Form");
        }
        var sortVal = $form.find('.category-radio:checked').val();  //用户选中的产品分类值
//        alert(sortVal);

//alert($self.data('level'))
//        alert(typeof isShowProductType);

        if(strParamsType!=''){
            $.get("/cooperate/myQuoted.html", {'cmd':'show','list':strParamsType,'isShowWhichType':isShowWhichType,'isShowProductType':isShowProductType,
                'isShowNum':isShowNum,'isShowSize':isShowSize,'isShowPower':isShowPower,'sortVal':sortVal,'fitSmallpoxType':fitSmallpoxType,
                'surfacePreparation':surfacePreparation, 'colorNum':colorNum, 'height':height},function( data ) {
                if(data){
					
					if(level > 0){
					  var $self = $("#typeSecond"+level );  
					}else{
					  var $self = $("#typeSecond");  
					}
					
					$self.html(data);
					
					//输入框blur
//					$self.find('.count-num').blur(function(){
//					    countProductSum(level,$self);
//					});
					
				   
				 }
            });
        }




    }






    var saveFlag=0;




//添加产品
    function addProduct(){
//        $(".aa").append(  $('#step2Form').clone(true));
        var length=$('.save').length;

        if(length>=30){
            alert('最多可添加30个产品');
           return false;
        }

 
         var jj =   $( ".content-form-box");
		 var jjl = jj.length;
		 
		 var lastResid = 0;
		 if($('#step2Form'+length).data('resId')){
		     lastResid = $('#step2Form'+length).data('resId');
		 }
		 
         $('#step2Form'+length).data('resId','')
		 
		 
         //克隆操作		 
         $("#step2Form").clone(true).attr("id",'step2Form'+length).insertBefore($(".aa"));

        //修改#step2Form的id值
        $('#step2Form'+length).data('resId',lastResid)
      
       for (var i=1; i<jj.length; i++){
            jj[i].setAttribute('id',"step2Form"+i);
            $(jj[i]).data('level',i);
            //$(jj[i]).data('resId','');
            saveFlag++;
       }
	   
	    


        //修改typeSecond的id值

        var bb =   $( ".typeSecond");
        for (var i=1; i<bb.length; i++){
            bb[i].setAttribute('id',"typeSecond"+i);
			$(bb[i]).data('level',i);
        }






//修改天花的name值
        var aa =   $( ".tianhua");
        for (var i=1; i<aa.length; i++){
            aa[i].setAttribute('id',"tianhua"+i);
			$(aa[i]).data('level',i);
        }


//修改墙板的name值
        var cc =   $( ".qiangban");
        for (var i=1; i<cc.length; i++){
            cc[i].setAttribute('id',"qiangban"+i);
            $(cc[i]).data('level',i);
        }


//修改灯具的name值
        var dd =   $( ".dengju");
        for (var i=1; i<dd.length; i++){
            dd[i].setAttribute('id',"dengju"+i);
            $(dd[i]).data('level',i);
        }


//修改风口的name值
        var ee =   $( ".fengkou");
        for (var i=1; i<ee.length; i++){
            ee[i].setAttribute('id',"fengkou"+i);
            $(ee[i]).data('level',i);
        }


//修改踢脚线的name值
        var ff =   $( ".tijiaoxian");
        for (var i=1; i<ff.length; i++){
            ff[i].setAttribute('id',"tijiaoxian"+i);
            $(ff[i]).data('level',i);
        }


//修改窗帘的name值
        var gg =   $( ".chuanglian");
        for (var i=1; i<gg.length; i++){
            gg[i].setAttribute('id',"chuanglian"+i);
            $(gg[i]).data('level',i);
        }

//修改天花下产品类型的属性值
        var gg =   $( ".productTypeSelect");
        for (var i=1; i<gg.length; i++){
			gg[i].setAttribute('id',"productTypeSelect"+i);
            $(gg[i]).data('level',i);
        }

//修改“保存”的name值
    var hh =   $( ".save");
    for (var i=1; i<hh.length; i++){
        hh[i].setAttribute('id',"save"+i);
        hh[i].setAttribute('name',"save"+i);
        hh[i].setAttribute('value',i);
        $(hh[i]).data('level',i);
    }


//修改“删除”的name值
        var kk =   $( ".del");
        for (var i=1; i<kk.length; i++){
            kk[i].setAttribute('id',"del"+i);
            kk[i].setAttribute('name',"del"+i);
            kk[i].setAttribute('value',i);
            $(kk[i]).data('level',i);
        }




//修改 的name值
        var ll =   $( ".typeSecond");
        for (var i=1; i<ll.length; i++){
            ll[i].setAttribute('id',"typeSecond"+i);
            ll[i].setAttribute('name',"typeSecond"+i);
            ll[i].setAttribute('value',i);
            $(ll[i]).data('level',i);
        }

        var mm =   $( ".typeSecondHalf");
        for (var i=1; i<mm.length; i++){
            mm[i].setAttribute('id',"typeSecondHalf"+i);
            mm[i].setAttribute('name',"typeSecondHalf"+i);
            mm[i].setAttribute('value',i);
            $(mm[i]).data('level',i);
        }

        var nn =   $( ".typeThird");
        for (var i=1; i<nn.length; i++){
            nn[i].setAttribute('id',"typeThird"+i);
            nn[i].setAttribute('name',"typeThird"+i);
            nn[i].setAttribute('value',i);
            $(nn[i]).data('level',i);
        }


        var oo =   $( ".typeFourth");
        for (var i=1; i<oo.length; i++){
            oo[i].setAttribute('id',"typeFourth"+i);
            oo[i].setAttribute('name',"typeFourth"+i);
            oo[i].setAttribute('value',i);
            $(oo[i]).data('level',i);
        }

        var pp =   $( ".typeFifth");
        for (var i=1; i<pp.length; i++){
            pp[i].setAttribute('id',"typeFifth"+i);
            pp[i].setAttribute('name',"typeFifth"+i);
            pp[i].setAttribute('value',i);
            $(pp[i]).data('level',i);
        }





    }



function countProductSum(level,$self){
  var arrCategory  = [
     {'name':'其他','unit':'㎡','sum':0},
	 {'name':'天花','unit':'㎡','sum':0},
	 {'name':'墙板','unit':'㎡','sum':0},
	 {'name':'灯具','unit':'个','sum':0},
	 {'name':'风口','unit':'个','sum':0},
	 {'name':'踢脚线','unit':'m','sum':0},
	 {'name':'窗帘','unit':'㎡','sum':0},
	]
	//计算统计值
	var $forms = $('.content-form-box');
	
	$forms.each(function(index, element) {
        var $this = $(this);
		
		var $category = $this.find('.product-category-radios');
		if($category.length > 0){
		    var sortVal = $category.find('.category-radio:checked').val();  //用户选中的产品分类值
	    }
	    //用户输入的产品数量值
        var $num= $this.find('.count-num');
        var numVal = $num.val();
		
		if(sortVal && numVal){
			arrCategory = countProductType(sortVal,numVal,arrCategory);
		}
		
    });//end each

   //输出结果
   var $countView = $('#count-view-box');
   var clen = arrCategory.length;
   var shtml = '<p>统计:</p>';
   shtml += '<table  border="0" cellspacing="1" cellpadding="0" >';
   for(var i=0;i<clen;i++){
	   if(i>0){
		 var $oCate = arrCategory[i];	
		 shtml += '<tr>';
		 shtml += '<td>'+$oCate['name']+'</td>';
		 shtml += ' <td>'+$oCate['sum']+$oCate['unit']+'</td>';
		 shtml += ' </tr>  ';
	   }
   }//end for
   shtml += '</table>';
   
   $countView.empty();
   $countView.html(shtml);
   
//   console.log(arrCategory)
   

}

function countProductType(sortVal,numVal,arrCategory){
	if(!sortVal || !numVal){
		return false;
	}
	var clen = arrCategory.length;
	if(clen > 0){
		  for(var i=0;i<clen;i++){
			  var $oCate = arrCategory[i];
			  if(sortVal==i){
//				 console.log(i+'=='+numVal);
				 var sum = $oCate['sum'];
				 sum = parseInt(numVal) + parseInt(sum);
				 $oCate['sum'] = sum;
			  }
		  }//end for
	   
	 return arrCategory;	
	}
}



        //显示点击产品类型后的内容
        function showBelow(obj){

            var $obj=$(obj);

            $typeSecondHalf=$obj.parent().parent();
//            console.log($typeSecondHalf)

            var level=$typeSecondHalf.data('level');
            if(level>0){
                var $categoryBox = $('#step2Form'+level);
            }else{
                var $categoryBox = $('#step2Form');
            }

            var sortVal=$categoryBox.find('.category-radio:checked').val();//用户选中的当前产品分类值



//            var sortVal = $('.category-radio:checked').val();  //用户选中的产品分类值


            if(sortVal!=3){
                $categoryBox.find('.typeThird').css('display','block');
            }

            var materialType = $categoryBox.find('.materialList:checked').val(); //用户选中的当前材料类型值


            var productTypeSelect=  $categoryBox.find('.productTypeSelect');
//            console.log(productTypeSelect);



                var productTypeSelectVal=productTypeSelect.val();//用户选中的当前产品类型值
//            alert(productTypeSelectVal)


                $.get("/cooperate/myQuoted.html", {'cmd':'showBelow','sortVal':sortVal,'productTypeSelectVal':productTypeSelectVal,
                   'materialType':materialType },function( data ) {
                 if(data){
                     if(level > 0){
                         var $self = $("#typeThird"+level );
                     }else{
                         var $self = $("#typeThird");
                     }

                     $self.html(data);


                 }
             });










        }


        // 点击材料类型
        function showTJXandCLtypeThird(obj){
            var $obj=$(obj);

//        console.log($obj.parent().parent().parent())

            var $typeSecond=$obj.parent().parent().parent();
            var value=$typeSecond.attr('value');
//            console.log(value)

            if(value>0){
                var $categoryBox = $('#step2Form'+value);
            }else{
                var $categoryBox = $('#step2Form');
            }





            $categoryBox.find('.typeFourth').css('display','none');

            var sortVal = $categoryBox.find('.category-radio:checked').val();  //用户选中的产品分类值
            if(sortVal==2){//墙板下 点击材料类型
                $categoryBox.find('.typeSecondHalf').css('display','block');
                $categoryBox.find('.typeFourth').css('display','none');

                var materialListVal=   $categoryBox.find('.materialList:checked').val(); //用户选中的材料类型值
                $.get("/cooperate/myQuoted.html", {'cmd':'showQBproductType','materialListVal':materialListVal,  },function( data ) {
                    if(data){

                     if(value > 0){
                         var $self = $("#typeSecondHalf"+value );
                     }else{
                         var $self = $("#typeSecondHalf");
                     }
                        $self.html(data);
                    }
                });
            }


            if(sortVal==5){//踢脚线下 点击材料类型
                $categoryBox.find('.typeFourth').css('display','block');
                var materialListVal=  $categoryBox.find('.materialList:checked').val(); //用户选中的材料类型值
                if(materialListVal==2){// 不锈钢
                    $categoryBox.find('.typeFifth').css('display','none');
                }

                $.get("/cooperate/myQuoted.html", {'cmd':'showTJXsurfacePreparation','materialListVal':materialListVal,  },function( data ) {
                    if(data){

                     if(value > 0){
                         var $self = $("#typeFourth"+value );
                     }else{
                         var $self = $("#typeFourth");
                     }
                        $self.html(data);
                    }
                });
            }
            if(sortVal==6){//窗帘下 点击铝合金

                var materialListVal=  $categoryBox.find('.materialList:checked').val(); //用户选中的材料类型值
                if(materialListVal==1){
                    $categoryBox.find('.typeFourth').css('display','block');
                    $.get("/cooperate/myQuoted.html", {'cmd':'showCLproductType'  },function( data ) {
                        if(data){

                            if(value > 0){
                                var $self = $("#typeFourth"+value );
                            }else{
                                var $self = $("#typeFourth");
                            }
                            $self.html(data);
                        }
                    });
                }

            }



        }

        var nowSelectPreparation = 0;
        //踢脚线下 点击表面处理
        function showTXJColorNum(obj){
            var $obj=$(obj);
            nowSelectPreparation = $(obj).val();//踢脚线下用户选中的表面处理值
			
            var $typeFifth=$obj.parent().parent();
            var value=$typeFifth.attr('value');
//            console.log(value)

            if(value>0){
                var $categoryBox = $('#step2Form'+value);
            }else{
                var $categoryBox = $('#step2Form');
            }

            $categoryBox.find('.typeFifth').css('display','none');

            var materialListVal= $categoryBox.find('.materialList:checked').val(); //用户选中的材料类型值

            var surfacePreparationSelect=$categoryBox.find(".surfacePreparationSelect");
//            console.log(surfacePreparationSelect)
            var surfacePreparationSelectVal=$obj.val();//用户选中的表面处理值
            if(materialListVal==1){
                if(surfacePreparationSelectVal==1||surfacePreparationSelectVal==2){
                    $categoryBox.find('.typeFourth').css('display','block');
                    $categoryBox.find('.typeFifth').css('display','block');
                    $.get("/cooperate/myQuoted.html", {'cmd':'showTXJColorNum','surfacePreparationSelectVal':surfacePreparationSelectVal  },function( data ) {
                        if(data){
                     if(value > 0){
                         var $self = $("#typeFifth"+value );
                     }else{
                         var $self = $("#typeFifth");
                     }
                            $self.html(data);
                        }
                    });
                }
            }else  if(materialListVal==2){
                $categoryBox.find('.typeFifth').css('display','none');
            }

        }






        //保存
        function saveform(obj){

            var name=obj.name;
            var value=obj.value;
            var id= $('#resId').val();
            var resId = 0;
            if(value>0){
                var $categoryBox = $('#step2Form'+value);
            }else{
                var $categoryBox = $('#step2Form');
            }


//表单验证


            //验证产品分类
            var productCategory = '';
            $categoryBox.find('.product-category-radios input').each(function(){
                if($(this).prop("checked")){
                    productCategory = $(this).val();
                }
            });
            if(productCategory==''){
                alert('请选择产品分类');
                return false;
            }


            //验证材料、灯具、风口类型
            var materialList='';
            $categoryBox.find('.typeRadio input').each(function(){
                if($(this).prop("checked")){
                    materialList = $(this).val();
                }
            });
            if(materialList==''){
                alert('请选择材料/灯具/风口类型');
                return false;
            }

            //验证产品、材料类型
            if( $categoryBox.find('.category-radio:checked').val()==1||$categoryBox.find('.category-radio:checked').val()==2||$categoryBox.find('.category-radio:checked').val()==3){
                var productType= $categoryBox.find('.productTypeSelect').val();
                if(productType==0){
                    alert('请选择产品/材料类型');
                    return false;
                }
            }


            if( $categoryBox.find('.category-radio:checked').val()==6 && $categoryBox.find('.materialList:checked').val()==1 ){
                var productType= $categoryBox.find('.productTypeSelect').val();
                if(productType==0){
                    alert('请选择产品/材料类型');
                    return false;
                }
            }


//窗帘下 点击材料类型
            if( $categoryBox.find('.typeFourth').css("display")=='block'){
                var productType= $categoryBox.find('.productTypeSelect').val();
                if(productType==0){
                    alert('请选择产品类型!');
                    return false;
                }
                //验证铝板厚度
                var aluminumSheetThickness= $categoryBox.find('.aluminumSheetThickness').val();
                if(aluminumSheetThickness==''){
                    alert('请输入铝片厚度!');
                    return false;
                }


            }


            //验证安装方式
            if( $categoryBox.find('.typeThird').css("display")=='block'   ){
                var installation='';
                $categoryBox.find('#installation input').each(function(){
                    if($(this).prop("checked")){
                        installation = $(this).val();
                    }
                });
                if(installation==''){
                    alert('请选择安装方式');
                    return false;
                }
            }



            //验证表面处理
            if($categoryBox.find('.category-radio:checked').val()==5){//踢脚线
                var $surfacePreparationSelect = $categoryBox.find('.surfacePreparationSelect');

                var surfacePreparationSelectB= nowSelectPreparation;

                if(surfacePreparationSelectB==0){
                    alert('请选择表面处理');
                    return false;
                }
            }

            if( $categoryBox.find('.category-radio:checked').val()==1||$categoryBox.find('.category-radio:checked').val()==2
                    ||$categoryBox.find('.category-radio:checked').val()==3||$categoryBox.find('.category-radio:checked').val()==4){
                var surfacePreparationSelectB = $categoryBox.find('.surfacePreparationSelect option:selected').val();
                if(surfacePreparationSelectB==0){
                    alert('请选择表面处理');
                    return false;
                }
            }


            // 验证国际色号
            var   productCategory = $categoryBox.find('.category-radio:checked').val();//用户选择的产品分类值
            var   materialType=$categoryBox.find('.materialList:checked').val();//用户选择的材料类型值
            var    productType=$categoryBox.find('.productTypeSelect option:selected').val();   //用户选择的产品类型
            var   surfacePreparationSelect =$categoryBox.find('.surfacePreparationSelect option:selected').val()//用户选择的表面处理方式
            
			var $color =$categoryBox.find('.colorNum');
			var colorNum=$color.val();//非踢脚线下用户输入的国际色号

			var TcolorNum=$categoryBox.find('.TcolorNum').val();//踢脚线下用户输入的国际色号

			
//			console.log($categoryBox.find('.TcolorNum'))

			
            if(productCategory==1||productCategory==3||productCategory==4){//天花、灯具、风口
                if(colorNum==''){
                    alert('请输入国际色号!');
                    return false;
                }
            }

            if(productCategory==2){//墙板
                if(materialType==1||materialType==3){//铝合金
                    if(colorNum==''){
                        alert('请输入国际色号~!');
                        return false;
                    }
                }

            }

            if(productCategory==5) {//踢脚线
                if(materialType==1){//铝合金
                    if(nowSelectPreparation ==1 ||  nowSelectPreparation ==2 ){//聚酯喷涂、氟碳喷涂
                        if(TcolorNum==''){
                            alert('请输入国际色号');
                            return false;
                        }
                    }
                }

            }



            //验证规格
            if( $categoryBox.find('.standard').css("display")!='none'){
                var standard= $categoryBox.find('.standard').val();
                if(standard==''){
                    alert('请输入规格');
                    return false;
                }
            }


            //验证厚度
            var thickness= $categoryBox.find('.thickness').val();
            if(thickness==''){
                alert('请输入厚度');
                return false;
            }

            //验证钢板厚度
            var stencilThickness= $categoryBox.find('.stencilThickness').val();
            if(stencilThickness==''){
                alert('请输入钢板厚度');
                return false;
            }


            //验证面板厚度
            var panelThickness= $categoryBox.find('.panelThickness').val();
            if(panelThickness==''){
                alert('请输入面板厚度');
                return false;
            }

            //验证背板厚度
            var backplaneThickness= $categoryBox.find('.backplaneThickness').val();
            if(backplaneThickness==''){
                alert('请输入背板厚度');
                return false;
            }

            //验证芯材厚度
            var coreThickness= $categoryBox.find('.coreThickness').val();
            if(coreThickness==''){
                alert('请输入芯材厚度');
                return false;
            }

            //验证总厚度
            var totalThickness= $categoryBox.find('.totalThickness').val();
            if(totalThickness==''){
                alert('请输入总厚度');
                return false;
            }

            //验证瓦楞芯厚度
            var corrugatedCoreThickness= $categoryBox.find('.corrugatedCoreThickness').val();
            if(corrugatedCoreThickness==''){
                alert('请输入瓦楞芯厚度');
                return false;
            }

            //验证瓦楞芯高度
            var corrugatedCoreHeight= $categoryBox.find('.corrugatedCoreHeight').val();
            if(corrugatedCoreHeight==''){
                alert('请输入瓦楞芯高度');
                return false;
            }


            //验证底宽
            var bottomWidth= $categoryBox.find('.bottomWidth').val();
            if(bottomWidth==''){
                alert('请输入底宽');
                return false;
            }

            //验证高度
            var height= $categoryBox.find('.height').val();
            if(height==''){
                alert('请输入高度');
                return false;
            }

            //验证衬板材料
            var liningMaterial= $categoryBox.find('.liningMaterial').val();
            if(liningMaterial==''){
                alert('请输入衬板材料');
                return false;
            }

            //验证衬板厚度
            var liningThickness= $categoryBox.find('.liningThickness').val();
            if(liningThickness==''){
                alert('请输入衬板厚度');
                return false;
            }

            //验证铝板厚度
            var aluminumPlateThickness= $categoryBox.find('.aluminumPlateThickness').val();
            if(aluminumPlateThickness==''){
                alert('请输入铝板厚度');
                return false;
            }


            //验证数量
            var num= $categoryBox.find('.count-num').val();
            if(num==''){
                alert('请输入数量');
                return false;
            }

            //验证功率
            if( $categoryBox.find('#power').css("display")=='block'){
                var power='';
                $categoryBox.find('#power input').each(function(){
                    if($(this).prop("checked")){
                        power = $(this).val();
                    }
                });
                if(power==''){
                    alert('请选择功率');
                    return false;
                }
            }


            //验证配合天花类型
            var fitSmallpoxType= $categoryBox.find('.fitSmallpoxType').val();
            if(fitSmallpoxType==0){
                alert('请选择配合天花类型');
                return false;
            }

            //验证尺寸
            if( $categoryBox.find('#size').css("display")=='block'){
                var size='';
                $categoryBox.find('#size input').each(function(){
                    if($(this).prop("checked")){
                        size = $(this).val();
                    }
                });
                if(size==''){
                    alert('请选择尺寸');
                    return false;
                }
            }

            resId = $categoryBox.data('resId');

//        console.log(obj);
//        console.log(resId);

            var productCategory = '';
            var materialType='';
            var luminaireType='';
            var tuyereType='';
            var productType='';
            var installation='';
            var surfacePreparationSelect='';
            var colorNum='';
            var TcolorNum='';
            var standard='';
            var thickness='';
            var panelThickness='';
            var backplaneThickness='';
            var coreThickness='';
            var totalThickness='';
            var corrugatedCoreThickness='';
            var corrugatedCoreHeight='';
            var bottomWidth='';
            var height='';
            var liningMaterial='';
            var liningThickness='';
            var num='';
            var aluminumSheetThickness='';
            var size='';
            var power='';
            var fitSmallpoxType='';
            var tjxheight='';
            var aluminumPlateThickness='';
            var  stencilThickness='';
            var  TsurfacePreparationSelect='';

            productCategory = $categoryBox.find('.category-radio:checked').val();//用户选择的产品分类值

            materialType=$categoryBox.find('.materialList:checked').val();//用户选择的材料类型值

            luminaireType=$categoryBox.find('.luminaireType:checked').val();//用户选择的灯具类型值

            tuyereType=$categoryBox.find('.tuyereType:checked').val();//用户选择的风口类型值

            productType=$categoryBox.find('.productTypeSelect option:selected').val();   //用户选择的产品类型

            installation = $categoryBox.find('.installation:checked').val();//用户选择的安装方式值

            surfacePreparationSelect=$categoryBox.find('.surfacePreparationSelect option:selected').val();   //用户选择的表面处理

            TsurfacePreparationSelect=nowSelectPreparation;   //踢脚线下用户选择的表面处理

//        if( $categoryBox.find('.typeFifth').css("display")!='none'   ){
//            colorNum=$categoryBox.find('.colorNum').val();//用户输入的国际色号
//        }

            if(productCategory==5){
                if(materialType==1){
                    if(TsurfacePreparationSelect==1||TsurfacePreparationSelect==2){
                        TcolorNum=$categoryBox.find('.TcolorNum').val();//用户输入的国际色号
                    }else{
                        TcolorNum='';
                    }
                }else{
                    colorNum='';
                }
            }else{
                colorNum=$categoryBox.find('.colorNum').val();//用户输入的国际色号
            }



            standard=$categoryBox.find('.standard').val();//用户输入的规格

            thickness=$categoryBox.find('.thickness').val();//用户输入的厚度

            panelThickness=$categoryBox.find('.panelThickness').val();//用户输入的面板厚度

            backplaneThickness=$categoryBox.find('.backplaneThickness').val();//用户输入的背板厚度

            coreThickness=$categoryBox.find('.coreThickness').val();//用户输入的芯材厚度

            totalThickness=$categoryBox.find('.totalThickness').val();//用户输入的总厚度

            corrugatedCoreThickness=$categoryBox.find('.corrugatedCoreThickness').val();//用户输入的瓦楞芯厚度

            corrugatedCoreHeight=$categoryBox.find('.corrugatedCoreHeight').val();//用户输入的瓦楞芯高度

            bottomWidth=$categoryBox.find('.bottomWidth').val();//用户输入的底宽

            height=$categoryBox.find('.height').val();//用户输入的高度

            liningMaterial=$categoryBox.find('.liningMaterial').val();//用户输入的衬板材料

            liningThickness=$categoryBox.find('.liningThickness').val();//用户输入的衬板厚度

            num=$categoryBox.find('.count-num').val();//用户输入的数量

            aluminumSheetThickness=$categoryBox.find('.aluminumSheetThickness').val();//用户输入的铝片厚度

            aluminumPlateThickness=$categoryBox.find('.aluminumPlateThickness').val();//用户输入的铝板厚度

            stencilThickness=$categoryBox.find('.stencilThickness').val();//用户输入的钢板厚度

            size=$categoryBox.find('.size:checked').val();//用户选中的尺寸

            power = $categoryBox.find('.power:checked').val();//用户选择的功率

            tjxheight = $categoryBox.find('.tjxheight:checked').val();//用户选择的踢脚线高度

            fitSmallpoxType=$categoryBox.find('#fitSmallpoxType option:selected').val();   //用户选择的配合天花类型

            $.get("/cooperate/myQuoted.html",
                    {'cmd':'save',
                        'name':name,
                        'id':id,
                        'resId':resId,
                        'value':value,
                        'productCategory':productCategory,
                        'materialType':materialType,
                        'luminaireType':luminaireType,
                        'tuyereType':tuyereType,
                        'productType':productType,
                        'installation':installation,
                        'surfacePreparationSelect':surfacePreparationSelect,
                        'TsurfacePreparationSelect':TsurfacePreparationSelect,
                        'colorNum':colorNum,
                        'TcolorNum':TcolorNum,
                        'standard':standard,
                        'thickness':thickness,
                        'panelThickness':panelThickness,
                        'backplaneThickness':backplaneThickness,
                        'coreThickness':coreThickness,
                        'totalThickness':totalThickness,
                        'corrugatedCoreThickness':corrugatedCoreThickness,
                        'corrugatedCoreHeight':corrugatedCoreHeight,
                        'bottomWidth':bottomWidth,
                        'height':height,
                        'liningMaterial':liningMaterial,
                        'liningThickness':liningThickness,
                        'aluminumSheetThickness':aluminumSheetThickness,
                        'aluminumPlateThickness':aluminumPlateThickness,
                        'stencilThickness':stencilThickness,
                        'power':power,
                        'fitSmallpoxType':fitSmallpoxType,
                        'num':num,
                        'size':size,
                        'tjxheight':tjxheight,
                        'saveFlag':saveFlag,

                    },
                    function( data ) {
                        if (data == 0) {
                            alert("保存失败!")
                        }else {
							nowSelectPreparation = 0;
                            $categoryBox.data('resId',data);
                            alert("保存成功!");
//                  $categoryBox.find('.save').attr("disabled", true);
//                  $categoryBox.find('.save').css('background-color','gray');

                            //统计


                            if(value > 0){
                                var $self = $("#typeSecond"+value );
                            }else{
                                var $self = $("#typeSecond");
                            }

                            if(value && $self){
//                     countProductSum(value,$self);
                            }



                        }
                    }
            );





        }


        //删除
        function dell(obj){
            var name=obj.name;
            var value=obj.value;
            var id= $('#resId').val();//url的id参数值
            var resId = 0;

            if(value>0){
                var $categoryBox = $('#step2Form'+value);
            }else{
                var $categoryBox = $('#step2Form');
            }

            resId = $categoryBox.data('resId');

            $.get("/cooperate/myQuoted.html",
                    {'cmd':'del',
                        'name':name,
                        'id':id,
                        'resId':resId,
                        'value':value,
                    },
                    function( data ) {
                        if (data == 1) {
                            alert("删除成功!")
//                            $categoryBox.css('display','none');
                            $categoryBox.find('.reset').trigger("click");//清空当前表单内容
                            $categoryBox.data('resId','')


                            //统计


//                            if(value > 0){
//                                var $self = $("#typeSecond"+value );
//                            }else{
//                                var $self = $("#typeSecond");
//                            }
//
//                            if(value && $self){
//                                countProductSum(value,$self);
//                            }


                        }else if(data == 0){
                            alert("删除失败!")
                        }else {

                            alert("删除失败!")

                        }
                    }
            );
        }


        function checkStep(){
            var id= $('#resId').val();
            $.get("/cooperate/myQuoted.html", {'cmd':'checkStep','id':id},function( data ) {
                if(data==0){
                    alert('请先保存')
                    return false;
                }else {
                    window.location.href='http://www.gzcanr.com/cooperate/myQuoted-cmd-enquiry3-id-'+id+'.html'
                }
            });


        }






</script>